/* GUI CONVERTED from mrmprp1f.p (converter v1.75) Sun Aug 13 17:21:51 2000 */
/* mrmprp1f.p - MRP DETAIL REPORT ITEM NUMBER SORT                      */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* web convert mrmprp1f.p (converter v1.00) Fri Oct 10 13:58:13 1997 */
/* web tag in mrmprp1f.p (converter v1.00) Mon Oct 06 14:18:56 1997 */
/*F0PN*/ /*K103*/ /*                                                    */
/*V8:ConvertMode=Report                                        */
/* REVISION: 7.5    LAST MODIFIED: 03/03/95     BY: tjs *J014*          */
/* REVISION: 8.6    LAST MODIFIED: 10/15/97     BY: ckm *K103*          */
/* REVISION: 8.6E   LAST MODIFIED: 04/13/98     BY: *J2JD* Sachin Shah  */
/* REVISION: 8.6E   LAST MODIFIED: 10/12/98     BY: *L0BY* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/13/00 BY: *N0KR* myb              */
/*J2JD* GROUPED MULTIPLE FIELD ASSIGNMENTS INTO ONE AND ADDED NO-UNDO
        WHEREVER MISSING FOR PERFORMANCE AND SMALLER R-CODE */


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

     {mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */
/*K103*/ {wbrp02.i}

     define new shared variable fcsduedate as date.
     define new shared variable fcssite    like si_site.
     define new shared variable fcspart    like pt_part.

     define shared variable part        like pt_part NO-UNDO.
     define shared variable part1       like pt_part NO-UNDO.
     define shared variable bom         like wo_bom_code NO-UNDO.
     define shared variable bom1        like wo_bom_code NO-UNDO.
     define shared variable site        like si_site NO-UNDO.
     define shared variable site1       like si_site NO-UNDO.
     define shared variable buyer       like pt_buyer NO-UNDO.
     define shared variable prod_line   like pt_prod_line NO-UNDO.
     define shared variable ptgroup     like pt_group NO-UNDO.
     define shared variable part_type   like pt_part_type NO-UNDO.
     define shared variable vendor      like pt_vend NO-UNDO.
     define shared variable pm_code     like pt_pm_code NO-UNDO.
     define shared variable show_base   like mfc_logical NO-UNDO.
     define shared variable frwrd       like soc_fcst_fwd.
     define shared variable bck         like soc_fcst_bck.

     define variable gross              as decimal
        format "->>>,>>>,>>9.9<<<<<<<<" NO-UNDO.
     define variable recpt              like gross NO-UNDO.
     define variable ord                like gross NO-UNDO.
     define variable qoh                like gross NO-UNDO.
     define variable due_date           like mrp_due_date NO-UNDO.
     define variable i                  as integer NO-UNDO.
     define variable j                  as integer NO-UNDO.
     define variable week               as integer NO-UNDO.
     define variable lead               as integer NO-UNDO.
     define variable detail             as character format "x(70)" NO-UNDO.
     define variable desc1              as character format "x(50)" NO-UNDO.
     define variable mrp_reqd           like pt_mrp NO-UNDO.
     define variable qty_oh             like in_qty_oh NO-UNDO.
     define variable get_1st_item       like mfc_logical NO-UNDO.

/*J2JD* THE IN_MSTR RECORD IS A BETTER CHOICE TO LOOP THROUGH SITE/PART */
/*J2JD*                       FILE RELATIONSHIPS                        */
/*J2JD** BEGIN DELETE **
*     for each si_mstr no-lock where
*     si_site >= site and si_site <= site1,
*     each pt_mstr no-lock where
*     pt_part >= part and pt_part <= part1:
**J2JD** END DELETE **/

/*J2JD* BEGIN ADD */
         for each in_mstr
         fields(in_mrp in_part in_qty_oh in_site) no-lock
          where in_site >= site and in_site <= site1
            and in_part >= part and in_part <= part1
            use-index in_site
             break by in_site by in_part:

            for first pt_mstr
            fields(pt_bom_code pt_buyer pt_cum_lead pt_desc1 pt_desc2 pt_group
                   pt_insp_lead pt_insp_rqd pt_iss_pol pt_joint_type pt_mfg_lead
                   pt_mrp pt_ms pt_ord_max pt_ord_min pt_ord_mult pt_ord_per pt_ord_pol
                   pt_ord_qty pt_part pt_part_type pt_plan_ord pt_pm_code pt_prod_line
                   pt_pur_lead pt_sfty_stk pt_sfty_time pt_timefence pt_um pt_vend
                   pt_yield_pct) no-lock
            where pt_part = in_part: end.
/*J2JD* END ADD */

        if (pt_prod_line = prod_line or prod_line = "") and
           (pt_group     = ptgroup   or ptgroup   = "") and
           (pt_part_type = part_type or part_type = "")
        then do:

/*J2JD*/   for first si_mstr fields(si_site) no-lock
/*J2JD*/   where si_site = in_site: end.

/*J2JD**   find first ptp_det no-lock where ptp_part = pt_part **/
/*J2JD**   and ptp_site = si_site no-error. **/

/*J2JD* BEGIN ADD */
            for first ptp_det
               fields(ptp_bom_code ptp_buyer ptp_cum_lead ptp_ins_Lead
                      ptp_ins_rqd ptp_iss_pol ptp_joint_type  ptp_mfg_lead
                      ptp_ms ptp_ord_max ptp_ord_min ptp_ord_mult ptp_ord_per
                      ptp_ord_pol ptp_ord_qty ptp_part ptp_plan_ord ptp_pm_code
                      ptp_pur_lead ptp_sfty_stk ptp_sfty_tme ptp_site
                      ptp_timefnce ptp_vend ptp_yld_pct)
                      no-lock where ptp_part = pt_part
                      and ptp_site = in_site: end.
/*J2JD* END ADD */
           if available ptp_det then do:
          if (ptp_buyer <> buyer and buyer <> "")
          or (ptp_vend <> vendor and vendor <> "")
          or (ptp_pm_code <> pm_code and pm_code <> "")
          or (not show_base and ptp_joint_type = "5")
          or (ptp_bom_code <> "" and
              (ptp_bom_code < bom or ptp_bom_code > bom1))
          or (ptp_bom_code = "" and
              (ptp_part     < bom or ptp_part     > bom1))
          then next.
           end.
           else do:
          if (pt_buyer <> buyer and buyer <> "")
          or (pt_vend <> vendor and vendor <> "")
          or (pt_pm_code <> pm_code and pm_code <> "")
          or (not show_base and pt_joint_type = "5")
          or (pt_bom_code <> "" and
              (pt_bom_code < bom or pt_bom_code > bom1))
          or (pt_bom_code = "" and
              (pt_part     < bom or pt_part     > bom1))
          then next.
           end.

           /* FIND in_mstr, mrp_det, fsworkfile AND PRINT */
           {mrmprp1h.i}

           
/*GUI*/ {mfguichk.i  &warn=yes} /*Replace mfrpchk*/

        end.
/*J2JD**     end. /* for each si_mstr, each pt_mstr */ **/
/*J2JD*/ end. /* for each in_mstr */
/*K103*/ {wbrp04.i}
